<?php
require_once('../../config.php');
Doctrine::loadModels('../../models');

	$query = new Doctrine_Query();
    $query->from('Agent a')
    			->where('a.agent_type_id = 15')
            	->orderby('a.name_full');
    $items = $query->execute();	
    
$dom = new DomDocument('1.0');
$dom->formatOutput = true;

$root = $dom->createElement( "results" );
$dom->appendChild( $root );

	foreach ($items as $item){
		$dn = $dom->createElement( "record" );
		$dn->setAttribute( 'data', $item['agent_id'] );
		$dn->setAttribute( 'label', $item['name_full'] );
		$root->appendChild( $dn );
}		

header( "Content-type: text/xml");
echo $dom->saveXML();
    
?>